package com.ymttest.database.mongo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.http.impl.cookie.PublicSuffixFilter;
import org.json.JSONArray;

import com.mongodb.BasicDBObject;
import com.ymt.core.tool.Logger;
import com.ymt.database.MongoDBDriver;
import com.ymttest.business.service.AssertService;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;

public class YmtBuyerProductWapper {
	
	MongoDBDriver mdd;
	public YmtBuyerProductWapper() throws Exception{
		mdd = new MongoDBDriver(EnvSetup.getSystemUrl("set5_mongoip"),27017, "YmtBuyerProduct");
		mdd.setPoolSize(Integer.valueOf(EnvSetup.getSystemUrl("mongoPoolSize")));
		mdd.auth("BuyerProductuser", "123456");
		mdd.selectCollection("ProductDetailModel");
	}
	/**
	 * @param limit
	 * @return [{_id=5808b2d1528ab6c782fb4307, ProductId=9cc4e75c-8c98-40e0-b583-cd4d453766c9, Title=自动化测试_立即上架商品 10-20 20:06:13, Introduction=自动化测试 发布商品, PicList=[ "http://pc1.img.ymatou.com/G01/shangou/M00/2A/17/rBBlD1eqnq-AEvUHAANhqAY9_CQ839_n_w_o.jpg"], ValidStart=Thu Oct 20 20:06:16 CST 2016, ValidEnd=Thu Oct 27 20:06:16 CST 2016, LimitNum=0, LimitNumStartTime=Thu Oct 20 20:06:16 CST 2016, MinCatalogPrice=10.00, MaxCatalogPrice=9999999999.00, SellerId=20573576, SellerName=fyftest1, BrandId=10145, BrandName=, BrandEnName=IBM, MasterCategoryId=1001, MasterCategoryName=手机数码、电脑, CategoryId=1002, CategoryName=手机通讯, ThirdCategoryId=1003, ThirdCategoryName=按键手机, CatalogType=0, DeliveryMethod=2, BondedArea=0, Freight=0.00, DeliveryTemplateId=, Weight=0.00, TariffType=0, CountryId=0, AddTime=Thu Oct 20 20:06:16 CST 2016, Action=0, IsNewDesc=true, LocalReturn=2, NoticeRisk=true, ProductCode=shangpinhuohao123456, NoReasonReturn=false, IsNew=true, IsTop=false, CatalogList=[ { "CatalogId" : "6e3bf281-6680-4954-856a-f22d1710172b" , "SKU" : "shangpinbianma123456" , "PropertyList" : [ { "Name" :  null  , "Value" :  null  , "PicUrl" :  null  , "Sort" : 1}] , "PriceList" : [ { "PriceType" : 0 , "Reason" : "原价" , "Price" : "99999999999999.00" , "ProductInActivityId" : 0} , { "PriceType" : 1 , "Reason" : "新客价" , "Price" : "88.8888" , "ProductInActivityId" : 0} , { "PriceType" : 2 , "Reason" : "VIP价" , "Price" : "9.00" , "ProductInActivityId" : 0} , { "PriceType" : 5 , "Reason" : "定金价" , "Price" : "0.00" , "ProductInActivityId" : 0}] , "StockList" : [ { "StockType" : 0 , "Reason" : "规格库存" , "Stock" : 300 , "ProductInActivityId" : 0}]}], Grade=B}]

	 * @throws Exception
	 */
	public List<Map> getLimit(int limit) throws Exception {
		
		ArrayList<Map> list = mdd.selectPartLimitToMap("{ProdId:{$ne:null}}",limit);
	    
	    return list;
	}
	
	public static void main(String[] args) throws Exception {
		 List<Map> a = new YmtBuyerProductWapper().getLimit(1);
		System.out.println(a);
	}   

}
